﻿using System;
using System.Collections.Generic;
using System.Text;
using com.lover.astd.common.logic;
using com.lover.astd.common.model;

namespace com.lover.astd.common.logicexe.economy
{
    public class StockExe : ExeBase
    {
        public StockExe() { _name = ConfigStrings.S_Stock; _readable = ConfigStrings.SR_Stock; }
        public override long execute()
        {
            Dictionary<string, string> conf = getConfig();
            if (!conf.ContainsKey(ConfigStrings.enabled) || !conf[ConfigStrings.enabled].ToLower().Equals("true")) return next_day();
            if (!conf.ContainsKey(ConfigStrings.stock_id)) return next_day();
            string buy_ids = conf[ConfigStrings.stock_id];

            MiscMgr mgr = ServiceFactory.getMiscManager();
            int result = mgr.handleStockInfo(_proto, _logger, buy_ids, _user);
            if (result == 2) return next_hour();
            else if (result == 3) return _user._stock_cd;
            else return next_halfhour();
        }
    }
}
